<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<div class="row">
	<div class="col-xs-12">
		<div class="btn-group m-b-1" role="group">
			<?php echo admin_tab_active($menu['transfer']['tab'], 'list');?>
		</div>
	</div>
</div>

<form method="get" class="form-inline m-b-xs" action="<?php echo url('transfer-list');?>">
	<div class="row">
		<div class="col-lg-3">
			<div class="form-group" style="width:100%;">
				<select name="status" class="form-control" style="width:100%;">
					<option value="-1">全部状态</option>
					<option value="0" <?php if($status==0){echo 'selected';} ?>>转账失败</option>
					<option value="1" <?php if($status==1){echo 'selected';} ?>>转账成功</option>
				</select>
			</div>
		</div>
		<div class="col-lg-3">
			<div class="form-group" style="width:100%;">
				<select class="form-control" name="channel" style="width:100%;">
					<option value="0">全部通道</option>
					<?php foreach($channels as $c){ ?>
					<option value="<?php echo $c['id'];?>" <?php if($channel==$c['id']){echo 'selected';} ?>><?php echo $c['name'];?></option>
					<?php } ?>
				</select>
			</div>
		</div>
		<div class="col-lg-3">
			<div class="form-group" style="width:100%;">
				<select name="dotype" class="form-control" style="width:100%;">
					<option value="-1">全部类型</option>
					<option value="0" <?php if($dotype==0){echo 'selected';} ?>>自动转账</option>
					<option value="1" <?php if($dotype==1){echo 'selected';} ?>>手动转账</option>
				</select>
			</div>
		</div>
		<div class="col-lg-3">
			<div class="form-group" style="width:100%;">
				<input type="text" class="form-control" name="order_site" placeholder="商户转账订单号" value="<?php echo $order_site?>" size="15" style="width:100%;">
			</div>
		</div>
	</div>
	<div class="row" style="margin-top:5px;">
		<div class="col-lg-2">
			<div class="form-group" style="width:100%;">
				<input type="text" class="form-control" name="order_alipay" placeholder="支付宝转账单据号" value="<?php echo $order_alipay;?>" size="15" style="width:100%;">
			</div>
		</div>
		<div class="col-lg-2">
			<div class="form-group" style="width:100%;">
				<input type="text" class="form-control" name="account" placeholder="收款方支付宝账户" value="<?php echo $account;?>" size="15" style="width:100%;">
			</div>
		</div>
		<div class="col-lg-5">
			<div class="form-group">
				<div class="input-group" style="background-color:#fff;">
					<span class="input-group-addon"><i class="icon icon-calendar"></i></span>
					<input type="text" name="fdate" class="form_datetime form-control" value="<?php echo $fdate;?>">
					<span class="input-group-addon">至</span>
					<input type="text" name="tdate" class="form_datetime form-control" value="<?php echo $tdate;?>">
				</div>
			</div>
		</div>
		<div class="col-lg-2">
			<button type="submit" class="btn btn-success" style="width:100%;">
				<i class="icon icon-search"></i>
				立即查询
			</button>
		</div>
		<div class="col-lg-1">
			<a class="btn btn-info" href="<?php echo url('transfer-list').$param.'&export=1';?>">导出</a>
		</div>
	</div>
</form>

<div class="row">
	<div class="col-lg-12">
		<div class="card">
			<div class="table-responsive">
				<table class="table" style="min-width: 800px">
					<thead>
						<tr>
							<th class="text-center">删除</th>
							<th class="text-center">转账账号</th>
							<th class="text-center">通道</th>
							<th class="text-center">商户转账订单号</th>
							<th class="text-center">支付宝转账单据号</th>
							<th class="text-center">金额</th>
							<th class="text-center">状态</th>
							<th class="text-center">类型</th>
                          	<th class="text-center">时间</th>
						</tr>
					</thead>
					<tbody id="userlist">
						<?php if($log){foreach($log as $l){ ?>
						<tr uid="<?php echo $l['id']; ?>">
							<td class="text-center"><input type="checkbox" name="delete" /></td>
							<td class="text-center"><?php echo $l['account']; ?></td>
							<td class="text-center"><?php echo $l['channel']; ?></td>
							<td class="text-center"><?php echo $l['order_site']; ?></td>
							<td class="text-center"><?php echo $l['order_alipay']; ?></td>
							<td class="text-center"><?php echo round($l['money'],2); ?> </td>
							<td class="text-center">
								<?php
								if($l['status']==1){
									echo '<b style="color:#16a085;">成功</b>';
								}else{
								?>
								<?php echo $l['fail_msg']; ?>
								<?php }?>
							</td>
							<td class="text-center"><?php echo $l['dotype']==1?'<b style="color:#16a085;">手动</b>':'自动'; ?></td>
                          	<td class="text-center"><?php echo date('Y-m-d H:i:s', $l['time']);?></td>
						</tr>
						<?php }} ?>
                      	<tr>
							<td class="text-center" colspan="4">&nbsp;</td>
                          	<td class="text-right">合计</td>
                          	<td class="text-center"><?php echo round($total['money_total'], 2); ?> </td>
							<td class="text-center" colspan="3">&nbsp;</td>
                        </tr>
					</tbody>
				</table>
			</div>
			<hr class="m-t-0" />
			<p><button class="btn btn-sm m-l-1" id="confirm">删除</button></p>
		</div>
		<nav class="text-center"><ul class="pagination"><?php echo $pagination; ?></ul></nav>
	</div>
</div>

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<script src="../view/js/datetimepicker.js" type="text/javascript"></script>

<script>
var jconfirm = $("#confirm");
var juserlist = $('#userlist');
// 删除选中的记录
jconfirm.on('click', function(){
	var jchecked = juserlist.find('input[name="delete"]').filter(function(){ return this.checked; });
	if(jchecked.length < 1) return alert("请选择要删除的转账记录");
	if(!window.confirm("确认删除？")) return false;
	jchecked.each(function() {
		jtr = $(this).parents('tr');
		var uid = jtr.attr('uid');
		$.xpost(xn.url('transfer-delete'), {id:uid}, function(code, message) {
			if(code != 0) $.alert(message);
			jtr.remove();
		});
	});
});

$('#nav_pc li.transfer, #nav_mobile li.transfer').tab('show');
</script>